/**
 * 
 */
package com.yiyunpower.test.portal.rest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import bo.UserCloud;

import com.yiyunpower.test.portal.bo.Proper;
import com.yiyunpower.test.portal.bo.Sdf;
import com.yiyunpower.test.portal.bo.TestPojo;
import com.yiyunpower.test.portal.service.TestService;

/**
 * @author jlzeng
 *
 */
@RestController
@RefreshScope
public class LoginControler {
	@Autowired
	private TestService service;

	@Autowired
	private Sdf crawlerConfig;

	@Value("logging.file")
	private String pro = "555";

//	@Value("${custom}")
//	private String config;

	@Autowired
	private Proper pro23;

	@RequestMapping(value = "/hello", method = RequestMethod.POST)
	public String hello(String param) {
		System.out.println(service.getdas());
		System.out.println(pro23.rewString);
		TestPojo pojoById = service.getPojoById(2);
		return pojoById.getName();
	}

	@RequestMapping(value = "/qq", method = RequestMethod.GET)
	public UserCloud get2(UserCloud cloud) {
		return cloud;
	}

	@RequestMapping("/info")
	public Map<String, String> getInfo(@RequestParam String name) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("name", name);
		return map;
	}

	@RequestMapping("/list")
	public List<Map<String, String>> getList() {
		List<Map<String, String>> list = new ArrayList<Map<String, String>>();
		Map<String, String> map = null;
		String property = System.getProperty("user.dir");
		System.out.println(property);
		for (int i = 1; i <= 5; i++) {
			map = new HashMap<String, String>();
			map.put("name", "Shanhy-" + i);
			list.add(map);
		}
		return list;
	}
}
